package Utils;

import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;

import javax.servlet.ServletOutputStream;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.Random;

/**
 * Created by 隼 on 2016/12/4.
 * 生成验证码
 */
public class verification {
    public static final char[] CHARS={'2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','J','K','L','M'
            ,'N','P','Q','R','S','T','U','V','W','X','Y','Z'};
    public static Random random=new Random();  //随机数
//返回六位随机数
    public static String getRandomString(){            //获取六位随机数
        StringBuffer buffer =new StringBuffer();       //字符串缓存
        for(int i=0;i<6;i++){
            buffer.append(CHARS[random.nextInt(CHARS.length)]);       //每次取一个字符
        }
        return buffer.toString();
    }
    public static Color getRandomColor(){                 //获取随机的颜色
        return new Color(random.nextInt(255),random.nextInt(255),random.nextInt(255));

    }

    public static Color getReverseColor(Color c){            //返回某颜色的反色
        return new Color(255-c.getRed(),255-c.getGreen(),255-c.getBlue());

    }
}
